import { getNotRegisterCode } from '@/api/code'
import { ref } from 'vue'

export default () => {
  const getNoRegisterCodeListLoading = ref(false)
  const getNoRegisterCodeListParam = ref<CodeAPIRequest.GetNoRegisterCodeList>({
    limit: 50,
    page: 0,
    model: '',
    code: '',
    registerCode: '',
  })
  const noRegisterCodeList = ref<Array<CodeNoRegisterCodeList>>([])
  const noRegisterCodeListTotal = ref(0)

  const getNoRegisterCodeList = async () => {
    getNoRegisterCodeListLoading.value = true
    const res = await getNotRegisterCode(getNoRegisterCodeListParam.value)
    getNoRegisterCodeListLoading.value = false
    noRegisterCodeList.value = res.data.data.rows
    noRegisterCodeListTotal.value = Number(res.data.data.total)
  }

  return {
    noRegisterCodeList,
    noRegisterCodeListTotal,
    getNoRegisterCodeListParam,
    getNoRegisterCodeListLoading,
    getNoRegisterCodeList,
  }
}
